<?php
namespace app\api\controller;

use \think\Validate;

class Index
{
    public function check()
    {
        $rule = [
            'name' => 'require|max:25',
            'age' => 'number|between:1,120',
            'email' => 'email'
            ];
        $msg = [
            'name.require' => '名称必填',
            'name.max' => '名称最多不能操作25个字符',
            'age.number' => '年龄必须是数字',
            'age.between' => '年龄只能在1到120之间',
            'email' => 'email格式错误'
            ];
        
        $data = input('post.');
        $validate = new Validate($rule,$msg);
        $result = $validate->check($data);
        if(!$result){
            dump($validate->getError());
        }
        
    }
    public function index()
    {
        return 'hellow world!';
    }
}
